// 专家介绍相关 API

import request from './index';
import type { ApiResponse } from '@/types/api';
import type { ExpertInfo } from '@/types/expert';
import { mockGetExperts, mockGetExpertDetail } from '@/mock/expert';

const USE_MOCK = import.meta.env.VITE_USE_MOCK === 'true';

/**
 * 获取所有专家信息
 */
export const getExperts = async (): Promise<ApiResponse<{ experts: ExpertInfo[] }>> => {
  if (USE_MOCK) {
    return mockGetExperts();
  }
  
  return request.get('/experts');
};

/**
 * 获取单个专家详情
 */
export const getExpertDetail = async (expertId: string): Promise<ApiResponse<ExpertInfo>> => {
  if (USE_MOCK) {
    return mockGetExpertDetail(expertId);
  }
  
  return request.get(`/experts/${expertId}`);
};